import { reqGetGoodDetailListData } from "@/api/index";
const state = {
  goodDetailInfo: {},
};
const actions = {
  async getGoodDetailListData({ commit }, id) {
    const result = await reqGetGoodDetailListData(id);
    if (result.code === 200) {
      commit("SAVE_GOOD_DETAIL_LIST_DATA", result.data);
    }
  },
};
const mutations = {
  SAVE_GOOD_DETAIL_LIST_DATA(state, data) {
    state.goodDetailInfo = data;
  },
  UPDATE_IMG_DEFAULT_URL(state, imgUrl) {
    state.goodDetailInfo.skuInfo.skuDefaultImg = imgUrl;
  },
};
const getters = {
  categoryView(state) {
    return state.goodDetailInfo.categoryView || {};
  },
  skuInfo(state) {
    return state.goodDetailInfo.skuInfo || {};
  },
  spuSaleAttrList(state) {
    return state.goodDetailInfo.spuSaleAttrList || [];
  },
};
export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
};
